package com.tramy.tencentbugly;

import androidx.annotation.NonNull;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
import com.tencent.bugly.Bugly;

@ReactModule(name = TencentBuglyModule.NAME)
public class TencentBuglyModule extends ReactContextBaseJavaModule {

    public static final String NAME = "TencentBugly";

    public TencentBuglyModule(ReactApplicationContext reactContext) {
        super(reactContext);
    }

    @Override
    @NonNull
    public String getName() {
        return NAME;
    }

    @ReactMethod
    public void init(String appID,
                     boolean isDebug,
                     Promise promise) {
        Bugly.init(getReactApplicationContext().getApplicationContext(), appID, isDebug);
        promise.resolve("");
    }

    @ReactMethod
    public void setUserId(String userId) {
        Bugly.setUserId(getReactApplicationContext().getApplicationContext(), userId);
    }

}
